import sqlite3

db_file = 'vuln.db'

db = sqlite3.connect(db_file)
db.text_factory = lambda x: str(x, 'gbk', 'ignore')
cursor = db.cursor()

sql = "select Plugin_ID, NAME, Risk, Description, Solution from VULNDB"
data = cursor.execute(sql).fetchall()
for i in data:
    plugin_id = i[0]
    name = str(i[1]).replace('"', '\'')
    risk = str(i[2]).replace('"', '\'')
    description = str(i[3]).replace('"', '\'')
    solution = str(i[4]).replace('"', '\'')

    sql = 'insert into  VULNDB_copy(Plugin_ID, NAME, Risk, Description, Solution) values({},"{}","{}","{}","{}")'.format(
        plugin_id, name, risk, description, solution)
    cursor.execute(sql)

db.commit()

db.close()

